# -*- conding:UTF-8 -*-

'''
@ Project: P7_project
@ File: login_util.py
@ Author: 罗婷
@ Date：2022/5/30 22:12
强制登录
'''
# 判断用户是否登录
from functools import wraps

from flask import g

# 强制登录
def login_required(func):
    @wraps(func)
    def wrap(*args, **kwargs):
        print('强制登录g.user_id:', g.user_id, 'g对象', g)
        if g.user_id:
            return func(*args, **kwargs)
        else:
            return {'msg': '请先登录'}, 401
    return wrap










